function ex2(C)
    % Executes everything for excersize 2.
    % C is the number of mixture components.
    
    %create test and training set
    [Train Test] = plotData();
    fprintf('Press any button to continue');
    waitforbuttonpress;

    % do em_mog twice, once for each category
    [LL1 mog1] = em_mog(Train(find(Train(:, 3)), :), C, 3, 0);
    [LL2 mog2] = em_mog(Train(find(Train(:, 4)), :), C, 3, 0);

    % Initialize test-set values
    PTest = zeros(size(Test, 1), 2);

    % Classify testset
    PTest(:, 1) = classifyMog(Test, mog1)
    PTest(:, 2) = classifyMog(Test, mog2)

    % initialize confusion matrix:
    tp1 = 0;
    tf1 = 0;
    tp2 = 0;
    tf2 = 0;

    for i=1:size(PTest, 1)
        % If classiffier says class = 1 and class actually is 1:
        if(PTest(i, 1) > PTest(i, 2))
            if(Test(i, 3))
                tp1 = tp1 + 1;
            else
                tf1 = tf1 + 1;
            end
        elseif(PTest(i, 2) >= PTest(i, 1))
            if(Test(i, 4))
                tp2 = tp2 + 1;
            else
                tf2 = tf2 + 1;
            end
        end
    end
    sprintf('true class1:\t\t%d\nfalse class1:\t%d\ntrue class2:\t\t%d\nfalse class2:\t%d\ncorrectly classified:\t%.2f%\n', tp1, tf1, tp2, tf2, ((tp1+tp2) / (tp1+tf1+tp2+tf2))*100)    
end

